<?php
namespace App\Api\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Api\Services\JsonService;
use App\Api\Models\SpeckillShoppingCard;

class SpeckillShoppingCardController extends Controller
{
    /**
     * 秒杀购物车查询
     * @param Request $request
     * @return array
     */
    public function getsecList(Request $request)
    {
        $validate = $request->validate(['user_id'=>['required','alpha:num']]);

        $allowField = [
            'seckill_name',
            'images',
            'price',
            'status'
        ];

        $selist = SpeckillShoppingCard::getSeckillList($validate['user_id'],$allowField);

        if($selist != []){
            return JsonService::success($selist);
        }
        return JsonService::fail('购物车是空的...');
    }
}